﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace CRMWebSite.Manage.SystemMaintain.StaffManagement
{
    public partial class StaffModify : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ShowInfo();
            }

        }
        /// <summary>
        /// 显示员工信息
        /// </summary>
        protected void ShowInfo()
        {
            //if (Request.QueryString["memberId"] != null)
            //{
            //    var memberId = int.Parse(Request.QueryString["memberId"].ToString());
            //    using (var client = ServiceLibiary.GetService.StaffService())
            //    {
            //        var result = client.GetMemberById(memberId);
            //        if (result != null)
            //        {
            //            this.txtName.Text = result.name;
            //            this.txtPosition.Text = result.name;
            //            this.txtTelphone.Text = result.name;
            //            this.txtDepartment.Text = result.name;
            //            this.txtEmail.Text = result.name;
            //            this.txtId.Text = result.account;
            //            this.ddlSex.Text = result.sex == true ? "男" : "女";
            //            this.ddlState.Text = result.state==true? "在职":"离职";
      
                       
            //        }
            //    }
            //}
        }
        /// <summary>
        /// 将修改后的信息保存到数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void imgbtnSave_Click(object sender, ImageClickEventArgs e)
        {
            //using (var client = ServiceLibiary.GetService.StaffService())
            //{
            //    var member = new StaffMangerService.Member();
            //    var memberId = int.Parse(Request.QueryString["memberId"].ToString());
            //    member.name = this.txtName.Text;
            //    member.telephone = this.txtTelphone.Text;
            //    member.account = this.txtId.Text;
            //    member.email = this.txtEmail.Text;
            //    member.department = this.txtDepartment.Text;
            //    member.position = this.txtPosition.Text;
            //    member.sex = this.ddlSex.Text == "男" ? true : false;
            //    member.state = this.ddlState.Text == "在职" ? true : false;
            //    member.password = FormsAuthentication.HashPasswordForStoringInConfigFile("1111", "MD5");
            //    //将主键id也赋给member这个实体，这样才是完整的实体，才能找到数据库
            //    member.id = memberId;
            //   // try
            //    //{
            //        client.ModifyMember(member);
            //        ClientScript.RegisterClientScriptBlock(this.GetType(), "key1", "<script>alert('修改成功！'); location.href='MainStaff.aspx' </script>");
            //   // }
            //   // catch (Exception)
            //    //{

            //      //  ClientScript.RegisterClientScriptBlock(this.GetType(), "key1", "<script>alert('信息填写错误！')</script>");
            //        //return;
            //   // }

           
                
            //}
        }
    }
}